home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UTIL / SCREEN / CURSES01 / minix / c / charins < prev    next >
Text File  |  1991-05-05  |  3KB  |  95 lines

  1. /****************************************************************/
  2. /* Winsch() routine of the PCcurses package            */
  3. /*                                */
  4. /****************************************************************/
  5. /* This version of curses is based on ncurses, a curses version    */
  6. /* originally written by Pavel Curtis at Cornell University.    */
  7. /* I have made substantial changes to make it run on IBM PC's,    */
  8. /* and therefore consider myself free to make it public domain.    */
  9. /*        Bjorn Larsson (...mcvax!enea!infovax!bl)    */
  10. /****************************************************************/
  11. /* 1.0:    Release:                    870515    */
  12. /****************************************************************/
  13. /* Modified to run under the MINIX operating system by Don Cope */
  14. /* These changes are also released into the public domain.      */
  15. /*                             900906  */
  16. /****************************************************************/
  17.  
  18. #include <curses.h>
  19. #include "curspriv.h"
  20.  
  21. /****************************************************************/
  22. /* Winsch() inserts character 'c' at the cursor position in    */
  23. /* window 'win'. The cursor is advanced.            */
  24. /****************************************************************/
  25.  
  26. int    winsch(win, c)
  27.   WINDOW    *win;
  28.   char    c;
  29.   {
  30.   int        *temp1;
  31.   int        *temp2;
  32.   int        *end;
  33.   int         x = win->_curx;
  34.   int         y = win->_cury;
  35.   int         maxx = win->_maxx;
  36.  
  37.   if((c < ' ') && (c == '\n' || c == '\r' || c == '\t' || c == '\b'))
  38.     return(waddch(win, c));
  39.   end = &win->_line[y][x];
  40.   temp1 = &win->_line[y][maxx];
  41.   temp2 = temp1 - 1;
  42.   if(c < ' ')                 /* if CTRL-char make space for 2 */
  43.     temp2--;
  44.   while (temp1 > end)
  45.     *temp1-- = *temp2--;
  46.   win->_maxchng[y] = maxx;
  47.   if ((win->_minchng[y] == _NO_CHANGE) || (win->_minchng[y] > x))
  48.     win->_minchng[y] = x;
  49.   return(waddch(win, c));        /* fixes CTRL-chars too */
  50.   } /* winsch */
  51.  
  52. /****************************************************************/
  53. /* Insch() inserts character 'c' at the cursor position in    */
  54. /* stdscr. The cursor is advanced.                */
  55. /****************************************************************/
  56.  
  57. int insch(c)
  58.   char c;
  59.   {
  60.   return(winsch(stdscr,c));
  61.   } /* insch */
  62.  
  63. /****************************************************************/
  64. /* Mvinsch() moves the stdscr cursor to a new position, then    */
  65. /* inserts character 'c' at the cursor position in stdscr. The    */
  66. /* cursor is advanced.                        */
  67. /****************************************************************/
  68.  
  69. int mvinsch(y,x,c)
  70.   int  y;
  71.   int  x;
  72.   char c;
  73.   {
  74.   if (wmove(stdscr,y,x) == ERR)
  75.     return(ERR);
  76.   return(winsch(stdscr,c));
  77.   } /* mvinsch */
  78.  
  79. /****************************************************************/
  80. /* Mvwinsch() moves the cursor of window 'win' to a new posi-    */
  81. /* tion, then inserts character 'c' at the cursor position in    */
  82. /* window 'win'. The cursor is advanced.            */
  83. /****************************************************************/
  84.  
  85. int mvwinsch(win,y,x,c)
  86.   WINDOW *win;
  87.   int  y;
  88.   int  x;
  89.   char c;
  90.   {
  91.   if (wmove(win,y,x) == ERR)
  92.     return(ERR);
  93.   return(winsch(win,c));
  94.   } /* mvwinsch */
  95.